<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <button @click="change1">出现hello组件</button>
        <button @click="change2">出现哈哈组件</button>
        <component :is="zujian"></component>
    </div>
</body>
<script src="./vue.min.js"></script>
<script>
    new Vue({
        el:"#app",
        data:{
            zujian:"haha"
        },
        methods: {
            change1(){
              this.zujian='hello';
            },
            change2(){
                this.zujian = "haha";
            }
        },
        components:{
            hello:{
                template:`<h1>hello 组件</h1>`
            },
            haha:{
                template:`<h1>哈哈 组件</h1>`
            }
        }
    })
</script>
</html>